/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package scrum;

import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import java.util.Random;

/**
 *
 * @author jorgeraulgrion
 */
    public class ColorJjPanel extends javax.swing.JPanel {
    private Color color1 = new Color(0,0,0);
    private Color color2 = new Color(0,0,0);
    private float tran= 0.8f;
    
    public ColorJjPanel(){
        
    }
    
    public ColorJjPanel(Color c1, Color c2){
        color1 = c1;
        color2 = c2; 
    }
    
     public void paint(Graphics g) {    
        Graphics2D g2 = (Graphics2D) g.create();
        Rectangle clip = g2.getClipBounds();                        
        g2.setPaint(new GradientPaint(0.0f, 0.0f, color1.darker(),0.0f ,getHeight(), color2.darker()));        
        g2.fillRect(clip.x, clip.y, clip.width, clip.height);    
                  
     }
    
    public void setRandomColor(){
        Random rand = new Random();
        this.color1 = new Color(rand.nextInt(255),rand.nextInt(255),rand.nextInt(255));
        this.color2 = new Color(rand.nextInt(255),rand.nextInt(255),rand.nextInt(255));
    }
    
    public void setVistaColor(){        
        this.color1 = new Color(66,111,166);
        this.color2 = new Color(103,174,118);        
    }
    
    
    protected void paintComponent(Graphics g) {
        Graphics2D g2 = (Graphics2D) g;
        g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
        RenderingHints.VALUE_INTERPOLATION_BILINEAR);
        AlphaComposite old = (AlphaComposite) g2.getComposite();
        g2.setComposite(AlphaComposite.SrcOver.derive(getTran()));
        super.paintComponent(g);
        g2.setComposite(old);
    }

    public float getTran() {
        return tran;
    }

    public void setTran(float tran) {
        this.tran = tran;
    }

    
    
}
